<?php 
 
class ErrorController extends Zend_Controller_Action  
{ 
     
    protected $_error = null; 
     
    public function init() 
    { 
		 
		$this->CONFIG = Zend_Registry::get('config');
		//$this->_helper->layout->disableLayout();
		$this->frontController = Zend_Controller_Front::getInstance();
        $this->_error = $this->getRequest()->getParam('error_handler'); 
    } 
     
    public function errorAction() 
    { 
        switch ($this->_error->type) { 
            case 'EXCEPTION_NO_CONTROLLER':
				 $this->render('notfound');  
                return; 
            case 'EXCEPTION_NO_ACTION': 
                 $this->render('notfound');  
                return; 
            case 'EXCEPTION_OTHER': 
                 $this->render('notfound'); 
                return; 
        } 
    } 
     
    public function UserInputAction() 
    { 
        if ($this->CONFIG->application_state == 'development') { 
           $response = $this->getResponse();
			$exceptions = $response->getException();
			throw  array_pop($exceptions);
        } else { 
            $this->render('notfound'); 
        } 
    } 
     
    public function NoAuthAction() 
    { 
        if ($this->CONFIG->application_state == 'development') { 
          $response = $this->getResponse();
			$exceptions = $response->getException();
			throw  array_pop($exceptions);
        } else { 
             $this->render('notfound');  
        } 
    } 
     
    public function notFoundAction() 
    { 
        if ($this->CONFIG->application_state == 'development') { 
			$response = $this->getResponse();
			$exceptions = $response->getException();
			throw  array_pop($exceptions);
        } else { 
			
            $this->render('notfound'); 
        } 
    } 
     
    public function serverErrorAction() 
    { 
		/*$writer = new Zend_Log_Writer_Stream('../tmp/logs/application_exception.log');
		$logger = new Zend_Log($writer);*/
		
		$response = $this->getResponse();
		$exceptions = $response->getException();
		/*
		foreach($exceptions as $exception)
		{
			//$logger->error($exception); 
		}*/
		
		
		//print_r($exceptions);
		/*
        if (defined('APPLICATION_STATE') && APPLICATION_STATE == 'development') { 
            $response = $this->getResponse();
			$exceptions = $response->getException();
			throw  array_pop($exceptions);
        } else { 
            $writer = new Zend_Log_Writer_Stream('../logs/application_exception.log'); 
            $logger = new Zend_Log($writer); 
            $logger->log(get_class($exception) . ' -> ' . $exception->getMessage(), Zend_Log::CRIT); 
            $this->_response->setHttpResponseCode(500); 
            $this->_response->setBody($this->render()); 
        } */
		$this->render('notfound'); 
    } 
     
} 
?>  